package log

import (
	"log"
	"os"
	"strings"
	"fmt"
	"runtime"
)

var infologger = log.New(os.Stdout,"[INFO]  ",log.Ltime | log.Lshortfile)
var errorlogger = log.New(os.Stdout,"[ERROR] ",log.Ltime | log.Lshortfile)
var debuglogger = log.New(os.Stdout,"[DEBUG] ",log.Ltime | log.Lshortfile)


func fileInfo(skip int) string {
	_, file, line, ok := runtime.Caller(skip)
	if !ok {
		file = "<???>"
		line = 1
	} else {
		slash := strings.LastIndex(file, "/")
		if slash >= 0 {
			file = file[slash+1:]
		}
	}
	return fmt.Sprintf("%s:%d", file, line)
}

func Info(v ...interface{}) {
	infologger.Output(2, fmt.Sprint(v...))
}

func Error(v ...interface{}) {
	errorlogger.Output(2, fmt.Sprint(v...))
}
func Debug(v ...interface{}) {
	debuglogger.Output(2, fmt.Sprint(v...))
}